<%-- 
    Document   : TableUpdate
    Created on : Dec 12, 2013, 7:34:47 AM
    Author     : Bimo
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title>Lihat Tabel Update Barang</title>
    </head>
    <body>
        <form method="post" >
            <h1 align="center" style="color:#00CCFF"> Halaman Manajer </h1>
            <h2 align="center" style="color:black"> Lihat Tabel Stock Barang </h2>
            <p>Pilih Lokasi Cabang : </p>
            <select name="LokasiCabang" size="1">
                <option value="0">--- Select ---</option>
                <option value="1">Cabang A</option>
                <option value="2">Cabang B</option>
                <option value="3">Cabang C</option>
            </select>
            <input type="submit" value="submit"  />
            <p></p>

            <%
                try {

                    Connection con = koneksi.CekKoneksi.open();
                    String kode = request.getParameter("LokasiCabang");
                    Statement stat = con.createStatement();
                    ResultSet rs = null;
                    String in1 = null;
                    if (kode.equals("1")) {
                        out.print("Tabel Barang Cabang A");
                        in1 = "select * from CABANGA ";
                        request.setAttribute("a", "CABANGA");

                    } else if (kode.equals("2")) {
                        out.print("Tabel Barang Cabang B");
                        in1 = "select * from CABANGb ";
                          request.setAttribute("a", "CABANGb");

                    } else if (kode.equals("3")) {
                        out.print("Tabel Barang Cabang C");
                        in1 = "select * from CABANGc ";
                          request.setAttribute("a", "CABANGc");

                    }
                    rs = stat.executeQuery(in1);


            %>
            <table border="1">
                <tr>
                    <td><div align="center"><strong>SLNO</strong></div></td>
                    <td>Kode Barang</td>
                    <td>Nama Barang</td>
                    <td>Harga Barang</td>
                    <td>Jumlah</td>
                    <td>Update</td>
                </tr>
                <%int icount = 0;

                    while (rs.next()) {
                        String kodeB = rs.getString("KODE_BARANG");

                %>


                <TR>
                    <td><div align="center"><%=++icount%></div></td>
                    <TD><%=rs.getString("KODE_BARANG")%></TD>
                    <TD><%=rs.getString("NAMA_BARANG")%></TD>
                    <TD><%=rs.getString("HARGA_BARANG")%></TD>
                    <TD><%=rs.getString("JUMLAH")%></TD>
                    <td><div align="center"><a href="UpdateHarga2.jsp?kodeB=<%=kodeB%>">Edit</a></div></td>
                </TR>
                <% }
                %>
            </table>
            <%
                    rs.close();
                } catch (Exception ex) {
                    out.println("Can't connect to database.");
                }
            %>
        </form>
    </body>
</html>
